#ifndef APPLICATION_H_
#define APPLICATION_H_

/// INCLUDES ///
#include "settings/player_settings.h"
#include "settings/layout.h"
#include "graphics/surface.h"
#include "graphics/screen.h"
#include "player_region.h"
#include "hand_region.h"
#include "puzzle_region.h"
#include "queue_region.h"
#include "alignment_region.h"
#include "battle_region.h"
#include "effects_manager.h"
#include "top_region.h"
#include <string>
////////////////

/// DEFINES ///
#define SCREEN_WIDTH 		1024
#define SCREEN_HEIGHT		768
#define SCREEN_BPP			32
#define MAX_FRAMERATE		60
#define PLAYER_FILENAME 	"player"
#define TOOLTIP_THRESHOLD	1000
//#define APPLICATION_DEBUG
///////////////

/**
* This class handles the main game loop as well as global functionality.
* 
* @author dfoelber
**/
class Application : public TopRegionListener
{
public:
	/**
	* Singleton accessor
	* 
	* @return Singleton instance
	**/
	static Application* GetManager();
	
	/**
	* Deconstructor
	**/
	virtual ~Application();
	
	/**
	* Loads everything.
	* 
	* TODO: Break up/monitor
	* 
	* @return Success
	**/
	bool Load();
	
	/**
	* Runs the game loop.
	**/
	void Run();
	
	/**
	* Signifies the end of a timer.
	* 
	* Overridden from TopRegionListener
	**/
	virtual void TimerCompleted();
	
	/**
	* Sets the fullscreen boolean.
	* 
	* @param fullscreen
	**/
	void SetFullscreen(bool fullscreen) { this->fullscreen = fullscreen; }
	
	/**
	* If the game should run in full screen.
	* 
	* @return fullscreen
	**/
	bool IsFullscreen() { return fullscreen; }
	
private:
	/**
	* Private constructor
	**/
	Application();
	
private:
	/// Singleton instance
	static Application* 			instance;
	/// The screen
	Screen*							screen;
	/// The current mouse X position
	int 							currentX; 
	/// The current mouse Y position
	int 							currentY;
	/// The current tooltip counter
	int 							tooltipCounter;
	/// The global message counter
	int								globalCounter;
	/// The global message threshold
	int								globalThreshold;
	
	/// The ai settings
	PlayerSettings					aiSettings;
	
	/// The player settings
	PlayerSettings 					playerSettings;
	/// The screen's layout
	Layout* 						layout;
	/// The screen's background
	Surface* 						background;
	/// The player's region
	PlayerRegion* 					playerRegion;
	/// The card region (the player's hand)
	HandRegion* 					handRegion;
	/// The alignment region
	AlignmentRegion* 				alignmentRegion;
	/// The queue region
	QueueRegion* 					queueRegion;
	/// The puzzle region (the player's gem board)
	PuzzleRegion* 					puzzleRegion;
	/// The top region
	TopRegion* 						topRegion;
	/// The battle region
	BattleRegion* 					battleRegion;
	/// If the user wants to quit
	bool							quit;
	/// If the game should be paused
	bool							paused;
	/// If the game is showing something to the user (TopRegion)
	bool							showTop;
	/// If the game has ended
	bool							ended;
	/// If the game should use fullscreen
	bool							fullscreen;
};

#endif /*APPLICATION_H_*/
